package com.kaifamiao.demo.d0824;

import com.kaifamiao.demo.d0805.A;

import java.time.temporal.WeekFields;
import java.util.Calendar;
import java.util.Date;

public class Demo02 {

    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();

        System.out.println(calendar.toInstant().toString());

//        calendar.add(Calendar.MONTH, -10);
//        calendar.clear(Calendar.YEAR);


//        calendar.set(Calendar.HOUR_OF_DAY, 14);
        System.out.println(calendar.toInstant().toString());

        System.out.println(calendar.get(Calendar.YEAR));
        System.out.println(calendar.get(Calendar.MONTH));
        System.out.println(calendar.get(Calendar.DATE));
        System.out.println(calendar.get(Calendar.DAY_OF_MONTH));
        System.out.println(calendar.get(Calendar.HOUR));
        System.out.println(calendar.get(Calendar.HOUR_OF_DAY));
        System.out.println(calendar.get(Calendar.MINUTE));
        System.out.println(calendar.get(Calendar.SECOND));
        System.out.println(calendar.get(Calendar.MILLISECOND));

        System.out.println(calendar.get(Calendar.WEEK_OF_MONTH));
        System.out.println(calendar.get(Calendar.WEEK_OF_YEAR));

        System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
        System.out.println(calendar.get(Calendar.DAY_OF_YEAR));

        System.out.println(calendar.getActualMaximum(Calendar.MONTH));


        System.out.println(calendar.getCalendarType());


        System.out.println(calendar.getFirstDayOfWeek());

        System.out.println();

        // Calendar --> Date
        Date date = calendar.getTime();
        Date.from(calendar.toInstant());
        // Date --> Calendar
        Date date2 = new Date(1000L * 60 * 60 * 24 * 365 * 52 + 1000L * 60 * 60 * 24 * 30 * 8);

        Calendar c = Calendar.getInstance();
        c.setTime(date2);
        System.out.println(date2);
        System.out.println(c.toInstant().toString());
    }
}
